package com.example.graduatetest.fragments;


import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.view.menu.MenuBuilder;
import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProviders;
import androidx.recyclerview.widget.RecyclerView;

import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.graduatetest.R;
import com.example.graduatetest.databinding.FragmentClassesBinding;
import com.example.graduatetest.view.model.ClassesViewModel;
import com.example.graduatetest.view.model.LoginViewModel;

import java.lang.reflect.Method;

/**
 * A simple {@link Fragment} subclass.
 */
public class ClassesFragment extends Fragment {

    private ClassesViewModel classesViewModel;
    private FragmentClassesBinding binding;

    public ClassesFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment

        if(classesViewModel == null){
            classesViewModel = new ClassesViewModel();
        }
        binding = DataBindingUtil.inflate(inflater, R.layout.fragment_classes, container, false);
        return binding.getRoot();

    }


    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        classesViewModel = ViewModelProviders.of(requireActivity()).get(ClassesViewModel.class);
        classesViewModel.init(requireActivity(),binding);

        binding.setClassesViewModel(classesViewModel);
        binding.setLifecycleOwner(this);

    }
}
